package cn.xshi.sys.web;

import java.util.List;
import cn.xshi.sys.form.SysMessageForm;
import cn.xshi.sys.form.SysNotifyReceiverForm;
import cn.xshi.sys.model.SysDyRemind;
import cn.xshi.sys.model.SysMessage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import cn.xshi.common.annotation.Auth;
import cn.xshi.common.base.BaseAction;
import cn.xshi.sys.model.SysNotifyReceiver;
import cn.xshi.sys.service.SysMessageService;
import cn.xshi.sys.service.SysNotifyReceiverService;
import org.springframework.web.bind.annotation.*;
import com.github.pagehelper.PageInfo;
import javax.annotation.Resource;
/**
 * @Desc 全局动态提醒
 * @Author 邓纯杰
 * @CreateTime 2012-12-12 12:12:12
 */
@RestController
@RequestMapping("/sysDyRemind")
@Api(value = "全局统一动态提醒API",tags = "全局统一动态提醒API",description = "全局统一动态提醒API")
public class SysDyRemindController extends BaseAction {

	@Resource
	private SysNotifyReceiverService sysNotifyReceiverService;

	@Resource
	private SysMessageService sysMessageService;

	/**
	 * 加载初始化列表数据并分页
	 * @param sysNotifyReceiverForm
	 * @return
	 */
	@ApiOperation(value="查询提醒信息", notes="查询提醒信息")
	@GetMapping(value="/list")
	@Auth(value = "/sysDyRemind/list",authenticationType = Auth.AuthorizationType.REQUIRED_LOGIN_NOT_AUTH)
	public SysDyRemind getXtDyRemindList(SysNotifyReceiverForm sysNotifyReceiverForm){
		SysDyRemind sysDyRemind = new SysDyRemind();
		//处理通知
		sysNotifyReceiverForm.setReceiveId(getCurrentAccountId());
		sysNotifyReceiverForm.setStatus(0);
		List<SysNotifyReceiver> sysNotifyReceiverList = sysNotifyReceiverService.getSysNotifyReceiverListByCondition(sysNotifyReceiverForm);
		PageInfo<SysNotifyReceiver> page = new PageInfo<SysNotifyReceiver>(sysNotifyReceiverList);
		sysDyRemind.setSysNotifyReceiverList(page.getList());

		//处理短消息
		SysMessageForm sysMessageForm = new SysMessageForm();
		sysMessageForm.setType(1);
		sysMessageForm.setToId(getCurrentAccountId());
		sysMessageForm.setIsRead(0);
		List<SysMessage> sysMessageList = sysMessageService.getSysMessageListByCondition(sysMessageForm);
		PageInfo<SysMessage> SysMessage = new PageInfo<SysMessage>(sysMessageList);
		sysDyRemind.setSysMessageList(SysMessage.getList());
		return sysDyRemind;
	}
}
